package com.zlt.bkparking.controller.parking;

import com.zlt.bkparking.service.UserService;
import com.zlt.bkparking.vo.Menu;
import com.zlt.bkparking.vo.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Slf4j
@Api(value = "RestController-Swagger调试",tags = "Swagger 调试")
@RestController()
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private UserService userService;


    @GetMapping("menu")
    public Result menu(){
        // 获取菜单数据
        List<Menu> menus = null;
        try {
            menus = userService.selectMenu();
            System.out.println("menus=="+menus);
            return menus==null ? Result.error("菜单查询异常") : Result.ok("查询成功",menus);
        } catch (Exception e) {
            e.printStackTrace();
            return  Result.error("菜单查询异常");
        }
    }
}
